// var pageNum = 1;
var pageSize = 20;
var total;
function _ajax(pn){
	$.ajax({
		url: baseurl + `/book/list?pageNum=${pn}&pageSize=${pageSize}`,
		type: 'get',
		dataType: 'json',
		async:false,
		success: function (e) {		
			total = e.data.total
			//list
			var booklist = e.data.list;
			for(let i = 0;i<booklist.length;i++){
				var serialization ;
				if(booklist[i].serialize == 1){
					serialization = "连载中"
				}
				else{
					serialization = "已完结"
				}
				var books = `<li>
				<a href="book.html?id=${booklist[i].id}">
					<p class="cover">
						<img src="${booklist[i].cover}" alt="">
					</p>
					<div class="bookmsg">
						<p class="name">${booklist[i].name}</p>
						<p class="lei">${booklist[i].nickName}&nbsp;&nbsp;|&nbsp;&nbsp;${serialization}&nbsp;&nbsp;|&nbsp;&nbsp;${booklist[i].typeDetail}</p>
						<p class="intro">${booklist[i].summarized}</p>
						<p class="updatetime">
							更新时间：${booklist[i].updateTime}
						</p>
					</div>
				</a>
			</li>`
			$("#booklist").append(books)
			} 
		}
	});
}
_ajax(1)
//分页
$('.M-box').pagination({
	totalData: total,
	showData: pageSize,
	coping: true,
	// mode: 'fixed',
	keepShowPN:true,
	prevContent: '上一页',
	nextContent: '下一页',
	callback:function(index){
		$("#booklist").empty();
		_ajax(index.getCurrent())
	}
});

